<link href="${base}/plugins/font-awesome-4.7.0/css/font-awesome.min.css" rel="stylesheet">
<link href="${base}/plugins/element-ui-2.4.11/index.css" rel="stylesheet">
<script src="${base}/plugins/vue-2.5.17/vue.js"></script>
<script src="${base}/plugins/element-ui-2.4.11/index.js"></script>
<script src="${base}/plugins/vue-2.5.17/axios.js"></script>
<script src="${base}/plugins/qs/require.js" ></script>
<script>
    var base = '${base}';
    function toIndex(){
        location.href=base+'/backstage/index';
    }
    axios.defaults.withCredentials=true;
    axios.defaults.baseURL = base;
    axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';

    require.config({
        baseUrl: '${base}/plugins/qs/',
        paths:{
            'qs': 'qs'
        }
    })
    var qs;
    if(document.body){
        var a=document.body.innerHTML;
        document.body.innerHTML=a.replace(/\ufeff/g,'');
    }

    require(["${base}/plugins/qs/qs.js"], function(qsjs){
        qs=qsjs;
    });

    var post=function(url,data,vue){
        var that=vue;
        return new Promise(function(resolve, reject){
            if(data&&data.timeModified){
                delete data.timeModified;
            }
            if(data&&data.timeCreate){
                delete data.timeCreate;
            }
            //删除对象的空属性
            for(var p in data){
                if(typeof(data[p]) != "function"){
                    if(data[p]==''){
                        delete data[p];
                    }
                }
            }
            axios.post(url, qs.stringify(data, { indices: false }), {
                    headers: {
                        "Content-Type": "application/x-www-form-urlencoded"
                    },
                    withCredentials: true
                }
            ).then(function (response) {

                if(typeof(response.data.code)!='undefined'){
                    if(response.data.code==1){
                        that.$message.error(response.data.msg);
                    }else{
                        if(response.data.msg){
                            that.$message({
                                message:response.data.msg,
                                type: 'success'
                            });
                        }
                    }
                }
                resolve(response);
            }).catch(function (error) {
                if( that.submitting){
                    that.submitting = false;
                }
                that.$message.error('服务器端出错，请稍后再试！');
                reject(error);
            });
        })
    };

    var get=function(url,data,vue){
        var that=vue;
        return new Promise(function(resolve, reject){
            //删除对象的空属性
            for(var p in data){
                if(typeof(data[p]) != "function"){
                    if(data[p]==''){
                        delete data[p];
                    }
                }
            }
            axios.get(url, qs.stringify(data, { indices: false }), {
                    headers: {
                        "Content-Type": "application/x-www-form-urlencoded"
                    },
                    withCredentials: true
                }
            ).then(function (response) {

                if(typeof(response.data.code)!='undefined'){
                    if(response.data.code==1){
                        that.$message.error(response.data.msg);
                    }
                }
                resolve(response);
            }).catch(function (error) {
                if( that.submitting){
                    that.submitting = false;
                }
                that.$message.error('服务器端出错，请稍后再试！');
                reject(error);
            });
        })
    };

</script>
<style>
    body{
        margin: 0px;
        padding:0px;
        height: 100%;
    }
    html{
        height: 100%;
    }
    #app {
        height: 100%;
    }
    [v-cloak] {
        display: none;
    }
</style>